/**
 * 功能描述
 */

define(function (require, exports, module) {
	var Subnav = require("subnav");
	var aw = require("ajaxwrapper");
	
    var instance = {
        initComponent: function (params,widget) {
        	var subnav = new Subnav({
        		parentNode: ".J-subnav",
        		model: {
        			title: "退证退费",
        			items: [{
        				id: "search",
        				type: "search",
        				placeholder: "会员证号/会员/合同号",
        				handler:function(str){
        					var grid = widget.get("grid");
        					aw.ajax({
        						url: "api/travelcontractrefund/searchrefund",
        						data: {
        							s: str,
        							properties: "travelContract.memberCertificates," +
        									    "travelContract.contactNo," +
        									     "travelContract.member.personalInfo.name",
        							fetchProperties: widget.constant.fetchProperties
        						},
        						dataType: "json",
        						success:function(data){
        							grid.setData(data);
        						}
        					});
        				}
        			},{
        				id: "status",
        				type: "buttongroup",
        				tip: "状态",
        				items: [{
        					key: "NoRefund",
        					value: "待退费"
        				},{
        					key: "Refund",
        					value: "已退费"
        				}],
        				handler: function(key,element){
        					widget.get("grid").refresh();
        				}
        			},{
        				id: "startDate",
			            type: "daterange",
			            tip:"开始时间",
			            ranges: {
			                "本年": [moment().startOf("years"), moment().endOf("years")],
			                "本月": [moment().startOf("month"), moment().endOf("month")]
			            },
			            defaultRange: "本年",
			            minDate: "1930-05-31",
			            maxDate: "2020-12-31",
			            handler: function(time) {
			            	widget.get("grid").refresh();
			            },
			            tip: "办理日期"
        			},{
        				id: "return",
        				type: "button",
        				text:"返回",
        				show:false,
        				handler: function(){
        					var from = widget.get("form");
        					form.reset();
        					widget.hide([".J-form",".J-coupongrid",".J-applicategrid"]).show([".J-grid"]);
        					widget.get("subnav").hide(["return"]).show(["status","startDate","search"]);
        				}
        			}]
        		}
        	});
        	widget.set("subnav",subnav);
        }
    };
    module.exports = instance;
});
